package IO流.image;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;

public class 太极 {
    public static void main(String[] args) throws Exception{
        BufferedImage i=new BufferedImage(800,800,2);
        //建立2D画笔
        var g=i.createGraphics();
        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);
        //设置颜色 设置图像
        g.setColor(Color.YELLOW);
        g.fillRect(0,0,800,800);
        //画线
        g.setColor(Color.red);
        g.setStroke(new BasicStroke(2));
        g.drawLine(400,0,400,800);
        g.drawLine(0,400,800,400);
        //画圆
        g.setColor(Color.white);
        g.fillArc(200, 200, 400, 400, 270, 180);
        g.setColor(Color.black);
        g.fillArc(200,200,400,400,90,180);
        g.setColor(Color.white);
        g.fillArc(300,200,200,200,90,180);
        g.setColor(Color.black);
        g.fillArc(300,400,200,200,270,180);
        g.setColor(Color.black);
        g.fillArc(350,250,100,100,0,360);
        g.setColor(Color.white);
        g.fillArc(350,450,100,100,0,360);

        //给图像命名
        ImageIO.write(i,"png",new File("e:\\image03.png"));
        //调用系统命令
        Runtime.getRuntime().exec("cmd /k start E:/image03.png");
    }
}
